package com.dom.stor.dao.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.dom.stor.dao.entity.TUserInfo;
import com.dom.stor.dao.mapper.TUserInfoMapper;
import com.dom.stor.dao.service.ITUserInfoService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * <p>
 * B_用户信息表 服务实现类
 * </p>
 *
 * @author xllei
 * @since 2018-11-17
 */
@Service
public class TUserInfoServiceImpl extends ServiceImpl<TUserInfoMapper, TUserInfo> implements ITUserInfoService {

    @Override
    public Map<Integer, String> getUserNameList(Integer memCode) {
        List<TUserInfo> userInfos = getUserList(memCode);
        return userInfos.stream().collect(Collectors.toMap(TUserInfo::getId, entity->{return entity.getUserName();}));
    }

    private List<TUserInfo> getUserList(Integer memCode){
        Wrapper<TUserInfo> wrapper = new EntityWrapper<>();
        wrapper.eq("mem_code", memCode);

        return this.selectList(wrapper);
    }
}
